 
package ibms_rcp.performance.parts;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;

import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.nebula.widgets.calendarcombo.CalendarCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class AssessPart {
	//部门
	private ComboViewer depComboViewer;
	private Combo depCombo;
	//员工编号
	private Text codeText;
	/*起始时间*/
	private CalendarCombo dateFromCombo;
	/*截止时间*/
	private CalendarCombo dateToCombo;
	//查询
	private Button queryButton;
	
	private TableViewer tableViewer;
	private Table table;
		
	@Inject
	public AssessPart(Composite parent) {
		//TODO Your code here
	}
	
	@PostConstruct
	public void postConstruct(final Composite parent) {
		GridLayout layout = new GridLayout(1, false);
		layout.marginWidth = 10;
		layout.marginHeight = 10;
		parent.setLayout(layout);
		
		Label title = new Label(parent, SWT.NONE);
		title.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
		title.setText("工作考核");
		
		Composite queryComposite = new Composite(parent, SWT.BORDER);
		queryComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
				1, 1));
		queryComposite.setLayout(new GridLayout(5, false));
		
		// 部门
		Label depLabel = new Label(queryComposite, SWT.RIGHT);
		depLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
				false, 1, 1));
		depLabel.setText("部门：");
		depComboViewer = new ComboViewer(queryComposite, SWT.READ_ONLY);
		depCombo = depComboViewer.getCombo();
		depCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1));
		depComboViewer.setContentProvider(ArrayContentProvider
				.getInstance());
		depComboViewer.setLabelProvider(new LabelProvider() {
			@Override
			public String getText(Object element) {
				//TODO 得到部门text
//						if (element instanceof Building) {
//							Building building = (Building) element;
//							return building.getEms_name();
//						}
				return super.getText(element);
			}
		});
		// TODO 获取部门数据
		
		//员工编号
		Label codeLabel = new Label(queryComposite, SWT.RIGHT);
		codeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		codeLabel.setText("员工编号：");
		codeText = new Text(queryComposite, SWT.BORDER);
		codeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		new Label(queryComposite, SWT.NONE);
		
		// 起始日期
		Label dateFromLabel = new Label(queryComposite, SWT.RIGHT);
		dateFromLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
				false, false, 1, 1));
		dateFromLabel.setText("从");
		dateFromCombo = new CalendarCombo(queryComposite, SWT.BORDER);
		dateFromCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1));
		
		// 截止日期
		Label dateToLabel = new Label(queryComposite, SWT.RIGHT);
		dateToLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
				false, false, 1, 1));
		dateToLabel.setText("到");
		dateToCombo = new CalendarCombo(queryComposite, SWT.BORDER);
		dateToCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1));
		
		//查询按钮
		queryButton = new Button(queryComposite, SWT.NONE);
		queryButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
				false, 1, 1));
		queryButton.setText("查询");
		
		tableViewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
		table = tableViewer.getTable();
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		TableViewerColumn seqViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn seqTableColumn = seqViewerColumn.getColumn();
		seqTableColumn.setResizable(false);
		seqTableColumn.setAlignment(SWT.CENTER);
		seqTableColumn.setWidth(40);
		seqTableColumn.setText("序号");
		
		TableViewerColumn depViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn depTableColumn = depViewerColumn.getColumn();
		depTableColumn.setResizable(false);
		depTableColumn.setAlignment(SWT.CENTER);
		depTableColumn.setWidth(100);
		depTableColumn.setText("部门");
		
		TableViewerColumn workerViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn workerTableColumn = workerViewerColumn.getColumn();
		workerTableColumn.setResizable(false);
		workerTableColumn.setAlignment(SWT.CENTER);
		workerTableColumn.setWidth(100);
		workerTableColumn.setText("员工");
		
		TableViewerColumn taskViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn taskTableColumn = taskViewerColumn.getColumn();
		taskTableColumn.setResizable(false);
		taskTableColumn.setAlignment(SWT.CENTER);
		taskTableColumn.setWidth(100);
		taskTableColumn.setText("工作");
		
		TableViewerColumn areaViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn areaTableColumn = areaViewerColumn.getColumn();
		areaTableColumn.setAlignment(SWT.CENTER);
		areaTableColumn.setWidth(200);
		areaTableColumn.setText("区域");
		
		TableViewerColumn finishViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn finishTableColumn = finishViewerColumn.getColumn();
		finishTableColumn.setResizable(false);
		finishTableColumn.setAlignment(SWT.CENTER);
		finishTableColumn.setWidth(50);
		finishTableColumn.setText("完成");//是、否
		
		TableViewerColumn beginViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn beginTableColumn = beginViewerColumn.getColumn();
		beginTableColumn.setResizable(false);
		beginTableColumn.setAlignment(SWT.CENTER);
		beginTableColumn.setWidth(150);
		beginTableColumn.setText("开始时间");
		
		TableViewerColumn endViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn endTableColumn = endViewerColumn.getColumn();
		endTableColumn.setResizable(false);
		endTableColumn.setAlignment(SWT.CENTER);
		endTableColumn.setWidth(150);
		endTableColumn.setText("完成时间");
		
		TableViewerColumn timeViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn timeTableColumn = timeViewerColumn.getColumn();
		timeTableColumn.setResizable(false);
		timeTableColumn.setAlignment(SWT.CENTER);
		timeTableColumn.setWidth(100);
		timeTableColumn.setText("耗时");
		
		TableViewerColumn videoViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn videoTableColumn = videoViewerColumn.getColumn();
		videoTableColumn.setResizable(false);
		videoTableColumn.setAlignment(SWT.CENTER);
		videoTableColumn.setWidth(150);
		videoTableColumn.setText("视频");
		
		TableViewerColumn operViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn operTableColumn = operViewerColumn.getColumn();
		operTableColumn.setResizable(false);
		operTableColumn.setAlignment(SWT.CENTER);
		operTableColumn.setWidth(100);
		operTableColumn.setText("审核");//优秀、合格、不合格
		
		TableViewerColumn chargerViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn chargerTableColumn = chargerViewerColumn.getColumn();
		chargerTableColumn.setResizable(false);
		chargerTableColumn.setAlignment(SWT.CENTER);
		chargerTableColumn.setWidth(100);
		chargerTableColumn.setText("审核人");
	}
	
	
	@PreDestroy
	public void preDestroy() {
		//TODO Your code here
	}
	
	
	
}